<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>
    <link rel="stylesheet" href="../../build/aui-css/css/bootstrap.css">
    <script src="../../build/aui/aui.js"></script>
    <style>
    #delegate, #delegateNative {
        margin: 30px;
    }
    </style>
</head>
<body class="yui3-skin-sam">
    <h1>AlloyUI - Datepicker</h1>
    <div id="delegate">
        <h2>Delegate on buttons (Japanese)</h2>
        <button class="btn btn-primary"><span class="glyphicon glyphicon-calendar"></span> Select the date</button>
        <button class="btn btn-default"><span class="glyphicon glyphicon-calendar"></span></button>
        <h2>Delegate on input text (Japanese)</h2>
        <input class="form-control" type="text" placeholder="mm/dd/yyyy">
        <br>
        <input class="form-control" type="text" placeholder="mm/dd/yyyy" value="10/14/1985">
        <br>
        <input class="form-control" type="text" placeholder="mm/dd/yyyy">
        <br>
        <h2>Delegate on textarea (en-US)</h2>
        <textarea class="form-control" type="text" placeholder="Day, Mon dd, yyyy">Wed, Aug 07, 2013 — Thu, Aug 08, 2013 — Sun, Aug 18, 2013</textarea>
    </div>

    <div id="delegateNative">
        <h2>Delegate on HTML5 input date</h2>
        <input class="form-control" type="date">
    </div>

    <script>
    YUI({ lang: 'ja', filter: 'raw' }).use('aui-datepicker', function(Y) {
        new Y.DatePicker({
            on: {
                selectionChange: function(event) {
                    Y.log(event.newSelection);
                }
            },
            popover: {
                zIndex: 1
            },
            panes: 1,
            trigger: '#delegate input, #delegate button'
        });
    });

    YUI({ lang: 'en-US', filter: 'raw' }).use('aui-datepicker', 'aui-datepicker-native', function(Y) {
        var datepicker = new Y.DatePicker({
            calendar: {
                selectionMode: 'multiple'
            },
            mask: '%a, %b %d, %Y',
            popover: {
                toolbars: {
                    header: [[
                        {
                            icon:'glyphicon glyphicon-trash',
                            label: 'Clear',
                            on: {
                                click: function() {
                                    datepicker.clearSelection();
                                }
                            }
                        },
                        {
                            icon:'glyphicon glyphicon-globe',
                            label: 'Travel date',
                            on: {
                                click: function() {
                                    datepicker.clearSelection();
                                    datepicker.selectDates(new Date(2015, 2, 3, 2, 0, 0));
                                }
                            }
                        }
                    ]]
                }
            },
            on: {
                selectionChange: function(event) {
                    Y.log(event.newSelection)
                }
            },
            panes: 2,
            trigger: '#delegate textarea'
        });

        new Y.DatePickerNative({
            on: {
                selectionChange: function(event) {
                    Y.log(event.newSelection);
                }
            },
            trigger: '#delegateNative input'
        });
    });
    </script>
</body>
</html>